import axios from "axios";

export function request(url, params){
    const instance = axios.create({
        baseURL: 'http://127.0.0.1:5000',
        timeout: 30000,

    });

    instance.interceptors.request.use(config => {
        // console.log('请求拦截器');
        return config
    }, err => {
        console.log(err);
    });

    instance.interceptors.response.use(config => {
        return config;
    }, err => {
        console.log([err]);
    });


    if (params) {
        params = {
            params: params
        }
        return instance.get(url, params)
    } else {
        return instance.get(url)
    }
}